//app.js
App({
  onLaunch: function () {
    // 展示本地存储能力
    // var logs = wx.getStorageSync('logs') || []
    // logs.unshift(Date.now())
    // wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        wx.request({
          url: this.globalData.prefix + '/wxAction/code2session.do',
          data: {
            code: res.code
          },
          success:(res)=>{
            this.globalData.userInfo = res.data.result
            if (this.wxloginCallback) {
              this.wxloginCallback(res)
            }
          }
        })
      }
    })
    // 获取用户信息
    
  },
  globalData: {
    userInfo: null,
    // prefix:'http://39.104.150.58/e-web',
    prefix:'http://localhost:8081/e-web',
  }
})

//common function
// 无icon提示
wx.$showToast = function(value) {
  wx.showToast({
    title: value,
    icon: 'none',
    duration: 2000
  })
}
